import request from '@/utils/request'

export function fetchList(params) {
  return request({
    url: '/shop-user/role/list',
    method: 'get',
    params: params
  })
}

export function createRole(data) {
  return request({
    url: '/shop-user/role/create',
    method: 'post',
    data: data
  })
}
// 删除用户
export function deleteUserInfo(data) {
  return request({
    url: '/user/deleteUserInfo',
    method: 'post',
    data: data
  })
}
// 修改用户
export function updateUserInfo(data) {
  return request({
    url: '/user/updateUserInfo',
    method: 'post',
    data: data
  })
}
// 新增用户
export function addUserInfo(data) {
  return request({
    url: '/user/addUserInfo',
    method: 'post',
    data: data
  })
}
// 获取用户列表
export function userList(params) {
  return request({
    url: '/user/list',
    method: 'get',
    params: params
  })
}
// 获取用户列表的角色列表
export function roleList(params) {
  return request({
    url: '/user/roleList',
    method: 'get',
    params: params
  })
}
// 角色页面--获取用户列表
export function getRoleList(params) {
  return request({
    url: '/role/getRoleList',
    method: 'get',
    params: params
  })
}
// 角色页面--用户权限分配
export function getMenuTree(params) {
  return request({
    url: 'role/getMenuTree',
    method: 'get',
    params: params
  })
}
// 角色页面--新增角色
export function addRoleInfo(data) {
  return request({
    url: '/role/addRoleInfo',
    method: 'post',
    data
  })
}
// 角色页面--修改角色
export function updateRoleInfo(data) {
  return request({
    url: '/role/updateRoleInfo',
    method: 'post',
    data
  })
}
// 角色页面--删除角色
export function deleteRoleInfo(data) {
  return request({
    url: '/role/deleteRoleInfo',
    method: 'post',
    data
  })
}
export function updateRole(id, data) {
  return request({
    url: '/shop-user/role/update/' + id,
    method: 'post',
    data: data
  })
}

export function updateStatus(id, params) {
  return request({
    url: '/shop-user/role/updateStatus/' + id,
    method: 'post',
    params: params
  })
}

export function deleteRole(data) {
  return request({
    url: '/shop-user/role/delete',
    method: 'post',
    data: data
  })
}

export function fetchAllRoleList() {
  return request({
    url: '/shop-user/role/listAll',
    method: 'get'
  })
}

export function listMenuByRole(roleId) {
  return request({
    url: '/shop-user/role/listMenu/' + roleId,
    method: 'get'
  })
}

export function listResourceByRole(roleId) {
  return request({
    url: '/shop-user/role/listResource/' + roleId,
    method: 'get'
  })
}

export function allocMenu(data) {
  return request({
    url: '/shop-user/role/allocMenu',
    method: 'post',
    data: data
  })
}

export function allocResource(data) {
  return request({
    url: '/shop-user/role/allocResource',
    method: 'post',
    data: data
  })
}
